package map_set.leetcode;

//165. 比较版本号

public class Num165 {
    public int compareVersion(String version1, String version2) {
        String[] data = version1.split("\\.");
        String[] data2 = version2.split("\\.");

        for (int n = 0; n < Math.max(version1.length(),version2.length()); n++) {
            int i =(n < data.length ? Integer.valueOf(data[n]) : 0);
            int j =(n < data2.length ? Integer.valueOf(data2[n]) : 0);
            if(i < j){
                return -1;
            }else if(i > j){
                return 1;
            }
        }
        return 0;
    }
}
